#pragma once

#include <winsock2.h>
#include <list>

#define VALIDATE_ME 190347137
#define MAX_LEN 1024

typedef DWORD DBAG;

DWORD WINAPI listening_socket(void *param);

enum NetType
{
  CONREQ = 10, DATAMES, DISCON, BROADCASTINGSERVERDATAFORCLIENTSTOCONNECT, KEASHERE/*aka ACK*/
};

struct NetMes
{
  int validation;
  NetType type;
  char data[MAX_LEN - sizeof(int) - sizeof(NetType)];
};

class ServerNetwork
{
public:
  ServerNetwork(void);
  ~ServerNetwork(void);

  char *recieve_udp(void);//checks if new messages are on socket

  //done?
  void broadcast(void);//new thread to broadcast ip/port
  void disconnect(void);//removes client from list
  void connect(void);//attempts to connect to an object that has called listen_udp
  std::list<NetMes> update(void);
  void send_udp(char *_data, UINT len);//sends _data to all connected clients
  void listen_udp(void);//new thread to handle connection requests, adds client to list

  std::list<sockaddr_in> clients;
  int err;
  sockaddr_in recvaddr;
  SOCKET recv_sock, send_sock;
  WSADATA wsadata;
  std::list<DBAG> joah_is_stupids;//thread handles
  std::list<NetMes> messages_on_the_recv_sock_socket;
};

class ClientNetwork
{
public:
private:
};
